<html>
<!-- =====================================================================

  File:      Generated file for Adventure Works Cycles Storefront Sample
  Summary:   Self-documentation for application
  Date:	     June 16, 2003

=====================================================================

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) 2003 Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= -->
<head>
  <link rel=stylesheet href=style.css>
</head>
<body>
<div class=SourcePanel style="font-size:12">
<pre style="background-color:white">
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Collections</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">ComponentModel</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Data</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Drawing</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">SessionState</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span>.<span style="color: #2040a0">WebControls</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span>.<span style="color: #2040a0">HtmlControls</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Threading</span><span style="color: #4444FF">;</span>
<span style="color: #0000FF"><strong>using</strong></span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Globalization</span><span style="color: #4444FF">;</span>

<span style="color: #008000">/* =====================================================================

  File:      OrderDetails.aspx.cs for Adventure Works Cycles Storefront Sample
  Summary:   Displays a summary of the selected order and the line items which are part of the order.
  Date:	     June 16, 2003

---------------------------------------------------------------------

  This file is part of the Microsoft SQL Server Code Samples.
  Copyright (C) Microsoft Corporation.  All rights reserved.

This source code is intended only as a supplement to Microsoft
Development Tools and/or on-line documentation.  See these other
materials for detailed information regarding Microsoft code samples.

THIS CODE AND INFORMATION ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

======================================================= */</span>

<span style="color: #0000FF"><strong>namespace</strong></span> <span style="color: #2040a0">Microsoft</span>.<span style="color: #2040a0">Samples</span>.<span style="color: #2040a0">SqlServer</span> <span style="color: #4444FF"><strong>{</strong></span>

    <span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">partial</span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">OrderDetailsPage</span> <span style="color: #4444FF">:</span> <span style="color: #2040a0">System</span>.<span style="color: #2040a0">Web</span>.<span style="color: #2040a0">UI</span>.<span style="color: #2040a0">Page</span>
    <span style="color: #4444FF"><strong>{</strong></span>


<span style="color: #008000">//         public OrderDetailsPage() {</span>
<span style="color: #008000">//             Page.Init += new System.EventHandler(Page_Init);</span>
<span style="color: #008000">//         }</span>

        <span style="color: #008000">//*******************************************************</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">// The Page_Load event on this page is used to obtain</span>
        <span style="color: #008000">// order information from a database and then update</span>
        <span style="color: #008000">// UI elements with them.</span>
        <span style="color: #008000">//</span>
        <span style="color: #008000">//*******************************************************</span>

        <span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">Page_Load</span><span style="color: #4444FF">(</span><span style="color: #2040a0">object</span> <span style="color: #2040a0">sender</span>, <span style="color: #2040a0">System</span>.<span style="color: #2040a0">EventArgs</span> <span style="color: #2040a0">e</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>

            <span style="color: #008000">// Obtain Order ID from QueryString</span>
            <span style="color: #0000FF"><strong>int</strong></span> <span style="color: #2040a0">OrderID</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">Int32</span>.<span style="color: #2040a0">Parse</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Request</span>.<span style="color: #2040a0">Params</span><span style="color: #4444FF">[</span><span style="color: #444444">&quot;OrderID&quot;</span><span style="color: #4444FF">]</span>, <span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Get the customer ID too</span>
            <span style="color: #2040a0">string</span> <span style="color: #2040a0">CustomerId</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">User</span>.<span style="color: #2040a0">Identity</span>.<span style="color: #2040a0">Name</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// Obtain Order Details from Database</span>
            <span style="color: #2040a0">OrdersDB</span> <span style="color: #2040a0">orderHistory</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">OrdersDB</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
            <span style="color: #2040a0">OrderDetails</span> <span style="color: #2040a0">myOrderDetails</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">orderHistory</span>.<span style="color: #2040a0">GetOrderDetails</span><span style="color: #4444FF">(</span><span style="color: #2040a0">OrderID</span>, <span style="color: #2040a0">CustomerId</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

            <span style="color: #008000">// if order was found, display it</span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">myOrderDetails</span> <span style="color: #4444FF">!</span><span style="color: #4444FF">=</span> <span style="color: #2040a0">null</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>

				<span style="color: #008000">// Bind Items to GridControl</span>
				<span style="color: #2040a0">GridControl1</span>.<span style="color: #2040a0">DataSource</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">OrderItems</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">GridControl1</span>.<span style="color: #2040a0">DataBind</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #008000">// Update labels with summary details</span>
				<span style="color: #2040a0">totalLabel</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">OrderTotal</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">orderNumberLabel</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">OrderID</span>.<span style="color: #2040a0">ToString</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CultureInfo</span>.<span style="color: #2040a0">InvariantCulture</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">orderDateLabel</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">OrderDate</span>.<span style="color: #2040a0">ToShortDateString</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">shipDateLabel</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">myOrderDetails</span>.<span style="color: #2040a0">ShipDate</span>.<span style="color: #2040a0">ToShortDateString</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">AddressLabelControls</span> <span style="color: #2040a0">billToLabels</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">AddressLabelControls</span><span style="color: #4444FF">(</span>
					<span style="color: #2040a0">billToAddressLine1</span>, <span style="color: #2040a0">billToAddressLine2</span>, <span style="color: #2040a0">billToAddressCity</span>,
					<span style="color: #2040a0">billToAddressStateProvince</span>, <span style="color: #2040a0">billToAddressPostalCode</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">AddressLabelControls</span> <span style="color: #2040a0">shipToLabels</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>new</strong></span> <span style="color: #2040a0">AddressLabelControls</span><span style="color: #4444FF">(</span>
					<span style="color: #2040a0">shipToAddressLine1</span>, <span style="color: #2040a0">shipToAddressLine2</span>, <span style="color: #2040a0">shipToAddressCity</span>,
					<span style="color: #2040a0">shipToAddressStateProvince</span>, <span style="color: #2040a0">shipToAddressPostalCode</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">CustomerAddresses</span> <span style="color: #2040a0">addresses</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">orderHistory</span>.
											  <span style="color: #2040a0">GetSalesOrderAddresses</span><span style="color: #4444FF">(</span><span style="color: #2040a0">OrderID</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>

				<span style="color: #2040a0">billToLabels</span>.<span style="color: #2040a0">FillControls</span><span style="color: #4444FF">(</span><span style="color: #2040a0">addresses</span>.<span style="color: #2040a0">BillingAddress</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">shipToLabels</span>.<span style="color: #2040a0">FillControls</span><span style="color: #4444FF">(</span><span style="color: #2040a0">addresses</span>.<span style="color: #2040a0">ShippingAddress</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
				<span style="color: #008000">// otherwise display an error message</span>
				<span style="color: #0000FF"><strong>else</strong></span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">MyError</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #444444">&quot;Order not found!&quot;</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">detailsTable</span>.<span style="color: #2040a0">Visible</span> <span style="color: #4444FF">=</span> <span style="color: #0000FF"><strong>false</strong></span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
        <span style="color: #4444FF"><strong>}</strong></span>

        <span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">Page_Init</span><span style="color: #4444FF">(</span><span style="color: #2040a0">object</span> <span style="color: #2040a0">sender</span>, <span style="color: #2040a0">EventArgs</span> <span style="color: #2040a0">e</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>
            <span style="color: #008000">//</span>
            <span style="color: #008000">// CODEGEN: This call is required by the ASP.NET Web Form Designer.</span>
            <span style="color: #008000">//</span>
            <span style="color: #2040a0">InitializeComponent</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span><span style="color: #4444FF">;</span>
        <span style="color: #4444FF"><strong>}</strong></span>

<span style="color: #0000ff"><strong>        #region Web Form Designer generated code</strong></span>
        <span style="color: #008000">/// &lt;summary&gt;</span>
        <span style="color: #008000">/// Required method for Designer support - do not modify</span>
        <span style="color: #008000">/// the contents of this method with the code editor.</span>
        <span style="color: #008000">/// &lt;/summary&gt;</span>
        <span style="color: #0000FF"><strong>private</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">InitializeComponent</span><span style="color: #4444FF">(</span><span style="color: #4444FF">)</span> <span style="color: #4444FF"><strong>{</strong></span>

        <span style="color: #4444FF"><strong>}</strong></span>
<span style="color: #0000ff"><strong>        #endregion</strong></span>

    <span style="color: #4444FF"><strong>}</strong></span>

	<span style="color: #008000">/// &lt;summary&gt;</span>
	<span style="color: #008000">///	Collects together a set of address label controls for simpler display code.	</span>
	<span style="color: #008000">/// Similar to AddressControls.  Perhaps use generics to combine at some point.</span>
	<span style="color: #008000">/// &lt;/summary&gt;</span>
 
	<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>class</strong></span> <span style="color: #2040a0">AddressLabelControls</span>
	<span style="color: #4444FF"><strong>{</strong></span>
		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">Label</span> <span style="color: #2040a0">line1</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">Label</span> <span style="color: #2040a0">line2</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">Label</span> <span style="color: #2040a0">city</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">Label</span> <span style="color: #2040a0">stateProvince</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>private</strong></span> <span style="color: #2040a0">Label</span> <span style="color: #2040a0">postalCode</span><span style="color: #4444FF">;</span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #2040a0">AddressLabelControls</span><span style="color: #4444FF">(</span><span style="color: #2040a0">Label</span> <span style="color: #2040a0">line1</span>, <span style="color: #2040a0">Label</span> <span style="color: #2040a0">line2</span>, <span style="color: #2040a0">Label</span> <span style="color: #2040a0">city</span>,
									<span style="color: #2040a0">Label</span> <span style="color: #2040a0">stateProvince</span>, <span style="color: #2040a0">Label</span> <span style="color: #2040a0">postalCode</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">line1</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">line1</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">line2</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">line2</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">city</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">city</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">stateProvince</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">stateProvince</span><span style="color: #4444FF">;</span>
			<span style="color: #0000FF"><strong>this</strong></span>.<span style="color: #2040a0">postalCode</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">postalCode</span><span style="color: #4444FF">;</span>
		<span style="color: #4444FF"><strong>}</strong></span>

		<span style="color: #0000FF"><strong>public</strong></span> <span style="color: #0000FF"><strong>void</strong></span> <span style="color: #2040a0">FillControls</span><span style="color: #4444FF">(</span><span style="color: #2040a0">CustomerAddress</span> <span style="color: #2040a0">ca</span><span style="color: #4444FF">)</span>
		<span style="color: #4444FF"><strong>{</strong></span>
			<span style="color: #0000FF"><strong>if</strong></span> <span style="color: #4444FF">(</span><span style="color: #2040a0">ca</span>.<span style="color: #2040a0">AddressID</span> <span style="color: #4444FF">&gt;</span> <span style="color: #4444FF">-</span><span style="color: #FF0000">1</span><span style="color: #4444FF">)</span>
			<span style="color: #4444FF"><strong>{</strong></span>
				<span style="color: #2040a0">line1</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ca</span>.<span style="color: #2040a0">Line1</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">line2</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ca</span>.<span style="color: #2040a0">Line2</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">city</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ca</span>.<span style="color: #2040a0">City</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">stateProvince</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ca</span>.<span style="color: #2040a0">StateProvinceName</span><span style="color: #4444FF">;</span>
				<span style="color: #2040a0">postalCode</span>.<span style="color: #2040a0">Text</span> <span style="color: #4444FF">=</span> <span style="color: #2040a0">ca</span>.<span style="color: #2040a0">PostalCode</span><span style="color: #4444FF">;</span>
			<span style="color: #4444FF"><strong>}</strong></span>
		<span style="color: #4444FF"><strong>}</strong></span>
	<span style="color: #4444FF"><strong>}</strong></span>
<span style="color: #4444FF"><strong>}</strong></span>

</pre>
